<?php
/**
 * 用户表模型
 * @author      HJC <hujianchuang@haowj.com>
 * @update      2014.06.23
 * @since       Version 1.0
 * 
 */
class UserModel extends Model
{
    //检查登录信息
    function checkLogin($haowj_ustat)
    {
        $mobile = $haowj_ustat['i'];
        if(!$mobile||strlen($mobile)!=11) return false;
        if($haowj_ustat['active']!='haowj') return false;
        //不做验证了 直接求出用户信息吧
        $condition = array('mobile'=>$mobile,'status'=>1);
        $userInfo  = $this->getInfo($condition);
        if(!$userInfo) return false;
        return $userInfo;
    }
    //根据条件获取单个会员信息
    public function getInfo($condition,$field='')
    {
        if(empty($condition)) return '';
        if(empty($field)) $field='*';
        $info = $this->where($condition)->field($field)->find();
        $info['user_name'] = $info['first_name'].' '.$info['last_name'];
        if($info['user_name']==' '||empty($info['user_name'])) $info['user_name'] = $info['name'];
        if($info['user_name']==' '||empty($info['user_name'])) $info['user_name'] = $info['mobile'];
        return $info;
    }
}